const path = require("path"),
  fs = require("fs-extra");

// 修改项目json文件
function updateProjectJson(gameName) {
  const filePath = path.join(__dirname, "projects.json");
  let projectsJson = fs.readJSONSync(filePath);
  projectsJson.lastRun = gameName;
  projectsJson[gameName] = path.join(__dirname, "..", "src", gameName);
  fs.writeJSONSync(filePath, projectsJson);
  return projectsJson;
}

// 获取项目名
function getPackageName() {
  const projectsJson = fs.readJSONSync(path.join(__dirname, "projects.json"));
  return projectsJson.lastRun;
}

module.exports = {
  updateProjectJson,
  getPackageName,
};
